const app = getApp();
const api = require('../../utils/api.js');
const util = require('../../utils/util.js');
const {
  $Toast
} = require('../../components/base/base');


Page({

  data: {
    navBg: app.globalData.navBg,
    navColor: app.globalData.navColor,
    windowHeight: app.globalData.windowHeight - app.globalData.navHeight,
    navTop: app.globalData.navHeight,
    back: true,
    navBox: true,
    home: true
  },

  savebtn: function() {
    // wx.navigateTo({
    //   url: '../scavengsuccess/scavengsuccess',
    // })
    util.navigateTo('../scavengsuccess/scavengsuccess')
  },

  savegift: function() {
    util.navigateTo('../scavenging/scavenging')
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    wx.showLoading({
      title: '加载中...',
    })
    wx.request({
      url: util.api + 'shopshopping/scanBuyorderitem.json',
      method: 'GET',
      header: {
        'Content-Type': 'application/json'
      },
      success: function(res) {

        var scanOrder = [];
        var scanOrderItem = [];
        for (var i = 0; i < res.data.data.length; i++) {
          scanOrder.push(res.data.data[i].scanBuyorderitem)
        }
        for (var i = 0; i < scanOrder[0].length; i++) {
          if (scanOrder[0][i].scanbuyorderid == options.id) {
            scanOrderItem.push(scanOrder[0][i])
          }
        }
        that.setData({
          scanOrderItem: scanOrderItem
        })
        console.log(options.id)
        wx.hideLoading()
      },
      fail: function(res) {
        wx.hideLoading()
      }

    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  }


})